using UnityEngine;
using UnityEngine.Events;

public class UIInlineMover : MonoBehaviour
{
	public float moveSpeed;

	public UnityEvent onAnimationEnd = new UnityEvent();

	public Vector3 from;

	public Vector3 to;

	private RectTransform target;

	public void Initialize(Vector3 from, Vector3 to, RectTransform target)
	{
		this.from = from;
		this.to = to;
		this.target = target;
	}

	private void Update()
	{
		Vector3 vector = Vector3.MoveTowards(from, to, moveSpeed * Time.deltaTime);
		target.anchoredPosition = vector;
		if (vector == to)
		{
			onAnimationEnd.Invoke();
			UnityEngine.Object.Destroy(this);
		}
	}
}
